package ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.devicecontroller.factories.imp;

import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;

import org.springframework.stereotype.Component;

import net.wimpi.modbus.io.ModbusTCPTransport;
import net.wimpi.modbus.io.ModbusTransport;
import ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.devicecontroller.factories.ModbusTransportFactory;

@Component
public class ModbusTransportFactoryImp implements ModbusTransportFactory {

	@Override
	public ModbusTransport connect(String ip, Integer port) {
		try {
			
			return new ModbusTCPTransport(new Socket(ip, port));
		} catch (UnknownHostException e) {
			return null;
		} catch (IOException e) {
			return null;
		}
	}

}
